﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using BUS;
using DTO;
namespace TuyenDungViecLam.User_control_VN
{
    public partial class Receive_Job_From_Company : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                LienKetDuLieu();
            }
        }

        private void LienKetDuLieu()
        {
            dldscongviec.DataSource = NguoiTimViec_BUS.DanhSachCacNhaTuyenDungDangKyNhanThongTin(int.Parse(Session["UserID"].ToString()));
            dldscongviec.DataBind();
        }

        protected void gvdscongviec_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridView gvdscongviec = (GridView)sender;
            gvdscongviec.PageIndex = e.NewPageIndex;
            Label lbmantd = (Label)gvdscongviec.Rows[0].Cells[0].FindControl("lbmantd");
            gvdscongviec.DataSource = ChiTietCongViec_BUS.DanhSachCacCongViecThuocNhaTuyenDung(lbmantd.Text);
            gvdscongviec.DataBind();
        }

        protected void dldscongviec_ItemCommand(object source, DataListCommandEventArgs e)
        {
            if (e.CommandName == "Delete")
            {
                NguoiTimViec_BUS.HuyNhanThongTinTuNhaTuyenDung(int.Parse(Session["UserID"].ToString()),int.Parse(e.CommandArgument.ToString()));
                LienKetDuLieu();
            }   
        }

        protected void dldscongviec_ItemDataBound(object sender, DataListItemEventArgs e)
        {
            ImageButton Delete = (ImageButton)e.Item.FindControl("Delete");
            Label lbTen = (Label)e.Item.FindControl("lbTen");
            Delete.OnClientClick = "if(!confirm('Bạn không muốn nhận thông tin việc làm từ " + lbTen.Text + "')) return false";
            Label lbmanhatuyendung = (Label)e.Item.FindControl("lbmanhatuyendung");
            GridView gvdscongviec = (GridView)e.Item.FindControl("gvdscongviec");
            gvdscongviec.DataSource = ChiTietCongViec_BUS.DanhSachCacCongViecThuocNhaTuyenDung(lbmanhatuyendung.Text);
            gvdscongviec.DataBind();
        }
    }
}